﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ServiceModel;

namespace WinFormApp
{
   public partial class Form1 : Form
   {
      ServiceHost host;

      public Form1()
      {
         InitializeComponent();
      }

      private void btStart_Click(object sender, EventArgs e)
      {
         Type serviceType = typeof(Service);
         host = new ServiceHost(serviceType);
         host.Open();
      }

      private void btStop_Click(object sender, EventArgs e)
      {
         if (host != null)
            host.Close();
      }

      protected override void OnClosed(EventArgs e)
      {
         if (host != null)
            host.Close();

         base.OnClosed(e);
      }
   }
}
